package com.aiguigu.admin.controller;

import com.aiguigu.admin.bean.User;
import com.aiguigu.admin.exception.UserTooManyException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;
import java.util.List;

@Controller
public class TableController {

    @GetMapping("/basic_table")
    public String basic_table(){

        //测试异常错误
        //int i=1/0;

        return "/table/basic_table";
    }


    @GetMapping("/dynamic_table")
    public String advance_table(Model model){
        //表格内容动态遍历
        List<User> users = Arrays.asList(new User("zhangsan", "123456"),
                new User("lisi", "123444"),
                new User("hahaha", "aaa"),
                new User("hehe", "321921679"));

        model.addAttribute("users",users);
        if (users.size()>3){
            throw new  UserTooManyException();
        }
        return "/table/dynamic_table";
    }

    @GetMapping("/responsive_table")
    public String responsive_table(){


        return "/table/responsive_table";
    }
    @GetMapping("/editable_table")
    public String editable_table(){

        return "/table/editable_table";
    }





}
